import Vue from 'vue'
import i18n from '@/lang'
// 重置浏览器css样式
import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import ElementUI from 'element-ui'
// 开发模式才引入,生产模式不用
if (process.env.NODE_ENV === 'development') {
  require('element-ui/lib/theme-chalk/index.css')
}
// import locale from 'element-ui/lib/locale/lang/en' // lang i18n

import '@/styles/index.scss' // global css
import echartPlugin from './utils/echartPlugin'
import App from './App'
import store from './store'
import router from './router'

import '@/icons' // icon
import '@/permission' // permission control
// 全局混入
import mixinFn from '@/mixin/index.js'
// 1. 导入全局指令
import * as directs from '@/directives'
console.log('导入所有指令对象', directs)
// 2.全局插件
import components from './components'
Vue.use(components)
// 1. 导入全局指令
Object.keys(directs).forEach(name => {
  Vue.directive(name, directs[name])
})

Vue.mixin(mixinFn)
Vue.use(echartPlugin)
/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online ! ! !
 */
// if (process.env.NODE_ENV === 'production') {
//   const { mockXHR } = require('../mock')
//   mockXHR()
// }

// set ElementUI lang to EN
// 注册组件库
Vue.use(ElementUI, {
  i18n: (k, v) => i18n.t(k, v)
})
// 如果想要中文版 element-ui，按如下方式声明
// Vue.use(ElementUI)

Vue.config.productionTip = false

new Vue({
  el: '#app',
  router,
  store,
  i18n,
  render: h => h(App)
})
